package com.spark.statistics

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.mllib.linalg.Vectors
import org.apache.spark.mllib.stat.Statistics

/**
  * Created by Administrator on 2017/8/22.
  */
object correlation {

  def main(args: Array[String]): Unit = {

    val conf=new SparkConf().setMaster("local").setAppName("statistics")
    val sc=new SparkContext(conf)
    val x=sc.parallelize(List(1,-1.0))
    val y=sc.parallelize(List(-2,2.0))
    val correlation=Statistics.corr(x,y,"pearson")

    println(correlation)




  }

}
